<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset=" utf-8">
<!--    <meta name="author" " />-->
    <title>getComputedStyle使用</title>
    <style type="text/css">
        div{
            width:100px;
            height:100px;
            margin-top:20px;
        }
        #first{background-color:red}
    </style>
    <script type="text/javascript">
        window.onload=function(){
            var first=document.getElementById("first");
            var second=document.getElementById("second");
            alert(window.getComputedStyle(first,null).backgroundColor);
            alert(second.style.backgroundColor);
        }
    </script>
</head>
<body>
<div id="first"></div>
<div id="second" style="background-color:blue"></div>
</body>
</html>